package com.ruoyi.framework.dataScope.strategy;

import com.ruoyi.project.system.domain.SysRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import java.util.*;

/**
 * @Classname CustomizeDataScope
 * @Description 自定义
 * @Author Created by Lihaodong (alias:小东啊) lihaodongmail@163.com
 * @Date 2019-06-08 16:31
 * @Version 1.0
 */
@Component("2")
public class CustomizeDataAuth implements AbstractDataAuthHandler {

    @Autowired
    @Qualifier("masterJdbcTemplate")
    private JdbcTemplate jdbcTemplate;

    @Override
    public List<Long> getDeptIds(SysRole role, String scopeType) {

        String sql="select dept_id as deptId from sys_role_dept where role_id= ?";
        List<Long> longs = jdbcTemplate.queryForList(sql, Long.class, role.getRoleId());
        return longs;
    }
}
